﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManageSystem
{
    public partial class MyBorrow : Form
    {
        private int count = 0;
        private string userId;
        public MyBorrow()
        {
            InitializeComponent();
            initData();
        }

        public MyBorrow(string userId)
        {
            InitializeComponent();
            this.userId = userId;
            initData();
        }

        private void MyBorrow_Load(object sender, EventArgs e)
        {
            if (count > 0)
            {
                MessageBox.Show("您有" + count + "本书最近将过期！");
            }
        }

        private void initData()
        {
            listView1.Items.Clear();
            string str = "select * from borrowInfo where userId=" + userId;
            SqlDataReader sdr = Utils.getDataReader(str);

            while (sdr.Read())
            {

                ListViewItem lv = new ListViewItem(sdr[6].ToString());
                lv.SubItems.Add(sdr[6].ToString());
                lv.SubItems.Add(sdr[1].ToString());
                lv.SubItems.Add(sdr[2].ToString());
                lv.SubItems.Add(sdr[3].ToString());
                listView1.Items.Add(lv);

                count++;

            }


        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
